﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;

namespace Twitter
{
    public static class BotClientExtensions
    {
		[Obsolete("Overloads to IMessages should be provided if this is really useful")]
		[EditorBrowsable(EditorBrowsableState.Never)]
        public static void SendMessages(this IBotClient client, string recipient, IEnumerable<string> messages)
        {
            foreach (string message in messages)
            {
                client.Messages.Send(recipient, message);
            }
        }

		[Obsolete("Overloads to IMessages should be provided if this is really useful")]
		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void SendMessages(this IBotClient client, string recipient, IEnumerable<string> messages, Message incomingMessage, string processorTypeName)
        {
            SendMessages(client, recipient, messages);

            // TODO: find a way into which its clear how many messages are sent
            string outgoingMessageText = messages == null ? null : messages.Aggregate(string.Empty, (a, b) => a + b);
            if (String.IsNullOrEmpty(outgoingMessageText))
                outgoingMessageText = null;
            string incomingMessageText = incomingMessage == null ? null : incomingMessage.Text;
            string twitterUser = incomingMessage == null ? null : incomingMessage.Sender.ScreenName;
            TwitterMessageLogger.AddLog(incomingMessageText, outgoingMessageText, processorTypeName, null, twitterUser);
        }
    }
}
